﻿
@model CommonStatisticsModel
@using Nop.Core
@using Nop.Services.Common
@using Nop.Services.Security

@{
    const string panelId = "nopcommerce-common-statistics-box";
    const string hidePanelAttributeName = "HideCommonStatisticsPanel";
    var hidePanel = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.GetAttribute<bool>(hidePanelAttributeName);
}

@if (Model.CanManage)
{
    <div class="box box-info @if (hidePanel)
    {<text>collapsed-box</text>}" id="@panelId">
        <div class="box-header with-border clearfix">
            <div class="box-title">
                <i class="fa ion-stats-bars"></i>
                @T("Admin.Dashboard.CommonStatistics")
            </div>
            <div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" data-widget="collapse">
                    @if (hidePanel)
                    {
                        <text><i class="fa fa-plus"></i></text>
                    }
                    else
                    {
                        <text><i class="fa fa-minus"></i></text>
                    }
                </button>
            </div>
        </div>
        <div class="box-body">
            @if (Model.CanManageMaintenances)
            {
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-aqua">
                        <div class="inner">
                            <h3>@Model.NumberOfMantance</h3>
                            <p>维修记录</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-settings"></i>
                        </div>
                        <a href="@Url.Action("List", "Maintenance")" class="small-box-footer">
                            @T("Admin.Dashboard.MoreInfo")
                            <i class="fa fa-arrow-circle-right"></i>
                        </a>
                    </div>
                </div>
            }
            else if (Model.CanManageMyMaintenances)
            {
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-aqua">
                        <div class="inner">
                            <h3>@Model.NumberOfMantance</h3>
                            <p>报修记录</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-settings"></i>
                        </div>
                        <a href="@Url.Action("MyList", "Maintenance")" class="small-box-footer">
                            @T("Admin.Dashboard.MoreInfo")
                            <i class="fa fa-arrow-circle-right"></i>
                        </a>
                    </div>
                </div>
            }
            @if (Model.CanManageInspectionsAll || Model.CanManageInspections)
            {
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-yellow">
                        <div class="inner">
                            <h3>@Model.NumberOfInspection</h3>
                            <p>巡检记录</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-navigate"></i>
                        </div>
                        <a href="@Url.Action("List", "Inspection")" class="small-box-footer">
                            @T("Admin.Dashboard.MoreInfo")
                            <i class="fa fa-arrow-circle-right"></i>
                        </a>
                    </div>
                </div>
            }
            @if (Model.CanManageOutsAudit || Model.CanManageOuts)
            {
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-green">
                        <div class="inner">
                            <h3>@Model.NumberOfEquipmentStockOut</h3>
                            <p>领用记录</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-log-out"></i>
                        </div>
                        <a href="@Url.Action("List", "EquipmentStockOut")" class="small-box-footer">
                            @T("Admin.Dashboard.MoreInfo")
                            <i class="fa fa-arrow-circle-right"></i>
                        </a>
                    </div>
                </div>
            }
            @if (Model.CanManageIns)
            {
                <div class="col-lg-3 col-xs-6">
                    <div class="small-box bg-red">
                        <div class="inner">
                            <h3>@Model.NumberOfEquipmentStockIn</h3>
                            <p>入库记录</p>
                        </div>
                        <div class="icon">
                            <i class="ion ion-log-in"></i>
                        </div>
                        <a href="@Url.Action("List", "EquipmentStockIn")" class="small-box-footer">
                            @T("Admin.Dashboard.MoreInfo")
                            <i class="fa fa-arrow-circle-right"></i>
                        </a>
                    </div>
                </div>
            }
            <script>
            $(document).ready(function () {
                $('#@panelId').on('click', 'button[data-widget="collapse"]', function () {
                    var collapsed = !$('#@panelId').hasClass('collapsed-box');
                    saveUserPreferences('@(Url.Action("SavePreference", "Preferences"))', '@hidePanelAttributeName', collapsed);
                });
            });
            </script>
        </div>
    </div>
}